<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>


</head>
<body>


<script type="text/javascript" src="/static/js/websocket-message-msg.js?v= {$random_number} "></script>
<script>

    var device_num = 'a12';

    var websocket = new initWebSocketMessage({
        onConnect: function () {
           // console.log("websocket 连接444");
            websocket.submit({Code: 0, Device_id: 0,From:'666'});
            //'{"Device_id":"97AC5E0886A442ABB45F6B035767A4F1","Adress":"成都市","Code":"10"}'

            setInterval(function () {
                //websocket.submit({Code: 10, Device_id: device_num});
                //websocket.submit({Code: '10', Device_id: "a12",Adress:"成都市"});
            }, 5000);

        },
        onDisconnect: function () {
            console.log("websocket 断开");
        },
        onUpdate: function (data) {
            //console.log('=='+data);
            if (data.indexOf('{') == -1){
                return;
            }
            data = JSON.parse(data);
            if (data.Code!=10){

            }
            console.log(data);
            switch (data.Code) {
                case 1:
                    console.log('收到打印信息');
                    setTimeout(function (){
                        data.Code = 30;
                        data.Message = 0;
                        websocket.submit(data);
                    },3000);
                    break;
                case 2:
                    // data.code = 31;
                    // data.message= "合格证打印完毕";
                    // websocket.submit(data);
                    break;
                default:
                    break
            }
        },
    })



</script>
</body>
</html>